﻿using MongoDB.Driver;
using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;
using Sustainalytics.Synchronization.Interface;
using Sustainalytics.SharedEntities.EsgResearch;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.IndicatorTemplateLogic
{
    public class IndicatorTemplateCommand : SyncEsgCommand<IndicatorTemplate>
    {
        private readonly IMongoCollection<IndicatorTemplate> indicatorTemplateCollection;

        public IndicatorTemplateCommand(IMongoCollection<IndicatorTemplate> indicatorTemplateCollection, ILogger logger) : base(logger)
        {
            this.indicatorTemplateCollection = indicatorTemplateCollection;
        }

        protected override async Task<DeleteResult> DeleteAssociatedRecordsAsync(IEnumerable<Guid> companiesIds = null, Guid? additionalDiscriminator = null)
        {
            return await indicatorTemplateCollection.DeleteManyAsync(Builders<IndicatorTemplate>.Filter.Empty).ConfigureAwait(false);
        }

        protected override async Task InsertRecordsAsync(IEnumerable<IndicatorTemplate> entities)
        {
            await indicatorTemplateCollection.InsertManyAsync(entities).ConfigureAwait(false);
        }
    }
}
